/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package convert;

import bean.WarehouseBean;
import ejb.Warehouse;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;

/**
 *
 * @author longdm
 */
public class warehouseConverter implements Converter {

    public Object getAsObject(FacesContext context, UIComponent component, String value) {
        WarehouseBean wb = new WarehouseBean();
        int id = Integer.parseInt(value);
        wb.setWarehouseId(id);
        return  wb.getWarehouseById();
    }

    public String getAsString(FacesContext context, UIComponent component, Object value) {
        return ((Warehouse)value).getWarehouseId().toString();

    }

}
